//
//  ByEmptyView.m
//  Homept_ios
//
//  Created by pro on 16/11/5.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ByEmptyView.h"

@implementation ByEmptyView
{
    // view
    UIImageView *_imageview;
    UILabel     *_titleLabel;
    
    // data
    ByEmptyMode _mode;
}
- (instancetype)initWithFrame:(CGRect)frame mode:(ByEmptyMode)mode {
    
    if (self = [super initWithFrame:frame]) {
        _mode = mode;
        self.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [self createViews];
    }
    
    return self;
}

- (void)createViews {
    
    NSString *title;
    NSString *imgName;
    switch (_mode) {
        case ByEmptyModeSignApply:
        {
            title = @"无签约申请";
            imgName = @"无签约订单";
            break;
        }
        case ByEmptyModeBespokeApply:
        {
            title = @"无预约申请";
            imgName = @"无签约订单";
            break;
        }
        case ByEmptyModeSignOrder:
        {
            title = @"无签约订单";
            imgName = @"无签约订单";
            break;
        }
        case ByEmptyModeBespoke:
        {
            title = @"无预约";
            imgName = @"无签约订单";
            break;
        }
        case ByEmptyModeMessage:
        {
            title = @"无消息";
            imgName = @"无消息界面";
            break;
        }
        case ByEmptyModeSearch:
        {
            title = @"没有搜到您想要的T.T";
            imgName = @"搜索为空";
            break;
        }
        case ByEmptyModeReport:
        {
            title = @"无发布内容";
            imgName = @"发布为空";
            break;
        }
        case ByEmptyModeRent:
        {
            title = @"无求租内容";
            imgName = @"发布为空";
            break;
        }
        case ByEmptyModeRepair:
        {
            title = @"无维修订单";
            imgName = @"无消息界面";
            break;
        }
        case ByEmptyModeCollection:
        {
            title = @"无收藏房源";
            imgName = @"发布为空";
            break;
        }
        case ByEmptyModeKeyLock:
        {
            title = @"您还没有电子钥匙";
            imgName = @"搜索为空";
            break;
        }
        default:
            break;
    }
    
    _imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width * 0.5, self.width * 0.5)];
    [_imageview setContentMode:UIViewContentModeScaleAspectFill];
    _imageview.image = [UIImage imageNamed:imgName];
    [self addSubview:_imageview];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.width, 20)];
    _titleLabel.font = FONT(18);
    _titleLabel.text = title;
    _titleLabel.textColor = HTB_THEME_COLOR;
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_titleLabel];
    
    _imageview.x = self.width / 2;
    _imageview.y = self.height / 2 - 40;
    
    _titleLabel.x = self.width / 2;
    _titleLabel.top = _imageview.bottom;
    
}

- (void)setTextColor:(UIColor *)textColor {
    
    _titleLabel.textColor = textColor;
}

@end
